/**
 * Created by hetanhong on 2014/9/11.
 */
(function () {
    var tongzhi2 = function (config) {
        this._config = config;
        this._type = this.getConfig("type"); //公文类别
        this._businessType = this.getConfig("businessType");
        this._title = this.getConfig("title");
        this._businessId = this.getConfig("businessId");
        this._id = this.getConfig("id"); //公文id
        this._businessId = this.getConfig("businessId");
        this._taskName = this.getConfig("businessTypeText") || "通知中心"; //流程名称
    };
    if (typeof (Clickmed) === "undefined") {
        Clickmed = {};
    }
    Clickmed.tongzhi2 = tongzhi2;
    tongzhi2.prototype.init = function () {
        var me = this;
        var url = serverURL + "cmcp/noticenter/phone/getNoticeInfo";
        window.plugins.getIntent.show(["OA", "正在获取数据"])
        var self = {
            id: me._id
        };
        PostCP(url, self, function (dat) {
            me.dat = dat;

            me.draw();
        }, function () {
            window.plugins.getIntent.hide();
            Alert("获取数据失败");
        })
        /*
         me.dat ={
         title:"关于市OA试运行的通知",
         creatPerson:"管理员",
         creatTime:"2014 -9 -12 :12:23",
         content:"测试公告，嗯，对的，好，来点图片啊，无所谓你确定<div class='uuu'><img src=../../common/page/images/gzdt.png>呵呵"

         };*/


    };
    tongzhi2.prototype.draw = function () {
        var me = this;
        var render = this._config.render || d3.select("body");
        var d1 = this._config.body || d3.select("body");
        var width = this.width;
        var scrol = d3.select("body").append("div").classed("scrol", true).style({
            position: "absolute",
            width: "100%",
            height: "100%",
            background:"#fff",
            "z-index":99,
            left: "0%",
            top: "0%"
        }).attr("id", "scrol");

        var warp = scrol.append("div").classed("dt_warp", true).style({
            position: "relative"
        });
        var datong_header = warp.append("div").classed("datong_header", true);

        var go_back = datong_header.append("div").classed("go_back", true);
        go_back.html("<i><img src =../../common/page/images/go_back_ico.png width =16 height=auto></i>返回");
        go_back.on(touch_s, function () {
            $(this).css("background-color", "#005ebf");
        });
        go_back.on(touch_e, function () {
            $(this).css("background-color", "");
            if (typeof (GLJ) != "undefined" && GLJ) {
                window.closeView();
                return;
            }

            d3.selectAll("#scrol").remove();
            setTimeout(function () {

                Android.back = TempFunction.back;
            }, Transiacion);

        });
        function back1() {

            d3.selectAll("#scrol").remove();
            setTimeout(function () {

            }, Transiacion);
            Android.back = TempFunction.back;
        }

        // Android返回键动作
        Android.back = TempFunction.back1 = back1;
        datong_header.append("h1").html(me._taskName || "通知公告");
        me.Redraw();

    };
    tongzhi2.prototype.Redraw = function () {
        var me = this;
        var dat = me.dat;
        var warp = d3.select("#scrol .dt_warp");
        var scrol_ = warp.append("div").classed("scrol_", true).style({
            width: "100%",
            height: height - 44 + "px",
            postion: "relative",
            overflow: "hidden"
        }).attr("id", "scrol_");
        var datong_con = scrol_.append("div").classed("datong_con datong_con_re", true);
        datong_con.append("div").classed("tongzhiTitle", true).style({
            "text-align": "center"
        }).html(dat["title"]);
        var datong_con = datong_con.append("div").classed("phone_cotent", true);
        var ul = datong_con.append("ul");
        var li = ul.append("li").classed("b_btm", true).style({
            width:"100%"
        });
        var table = li.append("table").attr("cellpadding", "0").attr('cellspacing', "0").style({
            width:"100%"
        });
        var tr = table.append("tr");
        tr.append("td").html("<div>创&nbsp; 建 &nbsp;人 </div>").style({
            width: "25%"
        });
        tr.append("td").style({
            width: "75%"
        }).append("div").html(dat["creatPerson"]).classed("extend",true);
        var tr = table.append("tr");
        tr.append("td").html("<div>创&nbsp;建&nbsp;时&nbsp;间 </div>").style({
            width: "25%"
        });
        tr.append("td").style({
            width: "75%"
        }).append("div").html(dat["creatTime"]).classed("extend",true);
        var ps_con = datong_con.append("div").classed("ps_con", true);
        ps_con.html(dat["content"]);
        new iScroll("scrol_", {hScrollbar: false, vScrollbar: false});
        ps_con.selectAll("a").attr("href","#");
        window.plugins.getIntent.hide();
    };
    tongzhi2.prototype.getConfig = function (key) {
        if (this._config == null) {
            return null;
        } else {
            if (typeof (this._config[key]) != "undefined") {
                return this._config[key];
            } else {
                return null;
            }
        }
    };
})();